module.exports = class extends think.Service {
  constructor() {
    super();
    const token = (this.token = "04yw0d0Oks28uJO7");
    const site = (this.site = "www.0537jinbuhuan.com");
    this.urlsUrl =
      "http://data.zz.baidu.com/urls?site=" + site + "&token=" + token;
    this.updateUrl =
      "http://data.zz.baidu.com/update?site=" + site + "&token=" + token;
    this.delUrl =
      "http://data.zz.baidu.com/del?site=" + site + "&token=" + token;
  }
  async urls(url) {
    const res = await this.fetch(this.urlsUrl, {
      method: "POST",
      headers: {
        "Content-Type": "text/plain"
      },
      body: "https://" + this.site + url
    }).then(res => res.json());
    return res;
  }
  async update(url) {
    const res = await this.fetch(this.updateUrl, {
      method: "POST",
      headers: {
        "Content-Type": "text/plain"
      },
      body: "https://" + this.site + url
    }).then(res => res.json());
    return res;
  }
  async del(url) {
    const res = await this.fetch(this.delUrl, {
      method: "POST",
      headers: {
        "Content-Type": "text/plain"
      },
      body: "https://" + this.site + url
    }).then(res => res.json());
    return res;
  }
};
